﻿using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
// using Unity.Physics;
using UnityEngine;


//public partial class MovementSystem : SystemBase
//{
//    protected override void OnUpdate()
//    {
//        var dt = SystemAPI.Time.DeltaTime;
//        /*
//        Entities.WithAll<PlayerTag>().ForEach((ref LocalTransform transform, in VelComp velComp) =>
//        {
//            transform.Position += velComp.value * math.forward(transform.Rotation) * dt;
//        }).ScheduleParallel();
//        */
//        Entities.WithAll<PlayerTag>().ForEach((MoveAspect moveAspect) =>
//        {
//            moveAspect.transform.ValueRW.Position += moveAspect.velComp.ValueRO.value * math.forward(moveAspect.transform.ValueRO.Rotation) * dt;
//        }).ScheduleParallel();
//    }
//}
[DisableAutoCreation]
public partial struct MovementSystem : ISystem
{
        [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        var dt = Time.deltaTime;

        //.WithEntityAccess()
        foreach (MoveAspect moveAspect in SystemAPI.Query<MoveAspect>())
        {
            moveAspect.transform.ValueRW.Position.xy += moveAspect.velComp.ValueRO.value.xy * dt;
            //moveAspect.transform.ValueRW.Position.xy += moveAspect.agent.ValueRO.velocity * dt;
        }
    }
}